package org.cuatrovientos.erp.business;

import java.util.List;

import org.apache.log4j.Logger;
import org.cuatrovientos.erp.dao.ProductDAOInterface;
import org.cuatrovientos.erp.model.Product;
import org.springframework.beans.factory.annotation.Autowired;


public class ProductBO implements ProductBOInterface {
	
	// Get log4j logger
	private static final Logger logger = Logger.getLogger(ProductBO.class);
	 
	@Autowired
    private ProductDAOInterface productDAO;

	@Override
	public Product selectById(int id) {
		logger.info("selectById: " + id);
		return productDAO.selectById(id);
	}

	@Override
	public List<Product> selectAll() {
		logger.info("selectAll: ");
		return productDAO.selectAll();
	}

	@Override
	public List<Product> search(String name) {
		logger.info("search : " + name);
		return productDAO.search(name);
	}

	@Override
	public void deleteById(int id) {
		logger.info("delete: " + id);
		 productDAO.deleteById(id);
	}

	@Override
	public void insert(Product product) {
		logger.info("insert: " + product);
		productDAO.insert(product);
	}

	@Override
	public void update(Product product) {
		logger.info("update: " + product);
		productDAO.update(product);
	}
}
